package com.mhc.haval.manager.impl;

import com.mhc.haval.dal.mapper.ext.CompanyExtMapper;
import com.mhc.haval.dal.model.CompanyDO;
import com.mhc.haval.dal.query.CompanyQuery;
import com.mhc.haval.manager.CompanyManager;
import com.subaru.common.query.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * Manager for Company.
 */

@Service
public class CompanyManagerImpl implements CompanyManager{

    
    @Autowired
    protected CompanyExtMapper companyExtMapper;
    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(CompanyQuery query){
        return companyExtMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(CompanyQuery query){
        return companyExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(CompanyDO record){
        return companyExtMapper.deleteByPrimaryKey(record);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(CompanyDO record){
        return companyExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<CompanyDO> selectByQuery(CompanyQuery query){
        return companyExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
    */
    @Override
    public PageResult<CompanyDO> selectByQueryWithPage(CompanyQuery query) {
        PageResult<CompanyDO> result = new PageResult<CompanyDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public CompanyDO selectByPrimaryKey(Long id){
        return companyExtMapper.selectByPrimaryKey(id);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective( CompanyDO record,  CompanyQuery query){
        return companyExtMapper.updateByQuerySelective(record,  query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery( CompanyDO record,  CompanyQuery query){

        return companyExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(CompanyDO record){
        return companyExtMapper.updateByPrimaryKeySelective(record);
    }
}